#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long ll;
const ll MOD=20101009;
const ll MAXN=1e7+7;
bool is_prime[MAXN];
ll prime[MAXN/2], p_cnt;
ll sum[MAXN],su[MAXN];
ll MDZZ;
void Init() {
	memset(is_prime, 1, sizeof(is_prime));
	p_cnt=0;
	sum[1]=1;
	for (ll i=2; i<MDZZ; ++i) {
		if (is_prime[i]) {
			prime[p_cnt++]=i;
			sum[i]=(1-i);
		}
		for (ll j=0; j<p_cnt&&i*prime[j]<MDZZ; ++j) {
			is_prime[i*prime[j]]=false;
			if (i%prime[j]==0) {
				sum[i*prime[j]]=sum[i];
				break;
			}
			else {
				sum[i*prime[j]]=((1-prime[j])*sum[i])%MOD;
			}
		}
	}
	su[0]=0;
	for (ll i=1; i<MDZZ; ++i) su[i]=(su[i-1]+i*sum[i])%MOD;
}
ll get_sum(ll n, ll m, ll t) {
	return ((((n/t)*(n/t+1)/2)%MOD)*(((m/t)*(m/t+1)/2)%MOD))%MOD;
}
ll ans(ll n, ll m) {
	ll len=min(n,m);
	ll res=0;
	ll last;
	for (ll i=1; i<=len; i=last+1) {
		last=min(n/(n/i), m/(m/i));
		res=(res+(get_sum(n,m,i)*(su[last]-su[i-1]))%MOD);
	}
	res%=MOD;
	return res;
}
int main() {
//	freopen("in1.txt", "r", stdin);
	ll n,m;
	ll res;
	cin>>n>>m;
//	while (cin>>n>>m) { 
		MDZZ=min(n,m)+23;
		Init();
		res=ans(n,m);
		if (res<0) res+=MOD;
		cout<<res<<endl;
//	}
	return 0;
} 

